package com.zzptc.myapplication1015;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Zhuce2Activity extends AppCompatActivity {
  Button zhuce1;
  EditText zhanghao1;
    EditText mima1;
    private static final String TAG = "Zhuce2Activity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zhuce2);

        init();
        event();
    }
    private void event() {
        zhuce1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Log.d（TAG，"你点击我了"）;
                //准备回传 1.获取值 2.保存值到意图 3.回传
                String zhang=zhanghao1.getText().toString().trim();
                Log.d(TAG, "");
                String ma=mima1.getText().toString().trim();
                if (zhang.equals("")||ma.equals("")){
                    Toast.makeText(Zhuce2Activity.this,"用户名或密码不能为空",Toast.LENGTH_SHORT).show();
                }else {
                    // Toast.makeText(Zhuce2Activity.this,zhang+"帐号已经注册",Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent();//回传数值
                    intent.putExtra("zhnaghao", zhang);
                    intent.putExtra("mima", ma);
                    setResult(2, intent);
                    finish();
                }
            }
        });
    }
    private void init() {
      zhanghao1=findViewById(R.id.zhanghao1);
      zhuce1=findViewById(R.id.zhuce1);
      mima1=findViewById(R.id.mima1);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
